package com.springboot.mybatis.service.impl;

import com.springboot.mybatis.entity.User;
import com.springboot.mybatis.mapper.UserMapper;
import com.springboot.mybatis.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
 *DATE:2025/7/9
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public User queryById(Integer id) {
        return userMapper.selectUserById(id);
    }

    @Override
    public List<User> queryByName(String name) {
        return userMapper.selectUsersByKeyword(name);
    }

    @Override
    public List<User> queryAll() {
        return userMapper.selectAllUsers();
    }

    @Override
    public void addUser(User user) {
        userMapper.insertUser(user);
    }

    @Override
    public void deleteUserById(Integer id) {
        userMapper.deleteUserById(id);
    }

    @Override
    public void updateUser(User user) {
        userMapper.updateUserById(user);
    }
}
